package timeRequiredToBuy;

public class Solution {
    public int timeRequiredToBuy(int[] tickets, int k) {
        //
        int ans = 0;
        for (int i = 0; i < k; i++) {
            tickets[i]--;
            ans++;
        }
        for (int i = 0; i < tickets.length; i++) {
            if(tickets[i]>=tickets[k]) {
                ans += tickets[k];
            }else {
                ans += tickets[i];
            }
        }
        return ans;
    }
}
